package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.ActionAdvertisement;

/**
 * 
 * @author 
 *
 */
@DAO
public interface ActionAdvertisementDAO{
	
	@SQL("SELECT * FROM ActionAdvertisement WHERE deleteFlag=1 #if(:t.title!=''){and title like '%##(:t.title)%' } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<ActionAdvertisement> query(@SQLParam("t") ActionAdvertisement actionAdvertisement);
	
	@SQL("SELECT count(*) FROM ActionAdvertisement WHERE deleteFlag=1 #if(:t.title!=''){and title like '%##(:t.title)%' } ")
    int querySize(@SQLParam("t") ActionAdvertisement actionAdvertisement);
    
    @SQL("select * from ActionAdvertisement where id=:1")
    ActionAdvertisement queryById(int id);
    
    @SQL("INSERT INTO ActionAdvertisement (title,carouselImage,releaseState,releaseAt,isOuterLink,pvNum,orderNum,deleteFlag,createUser,createAt,updateUser,updateAt) VALUES (:t.title,:t.carouselImage,:t.releaseState,:t.releaseAt,:t.isOuterLink,:t.pvNum,:t.orderNum,1,:t.createUser,now(),:t.updateUser,now())")
    void create(@SQLParam("t") ActionAdvertisement actionAdvertisement);
	
	@SQL("UPDATE ActionAdvertisement SET title=:t.title,carouselImage=:t.carouselImage,releaseAt=:t.releaseAt,isOuterLink=:t.isOuterLink,orderNum=:t.orderNum,updateUser=:t.updateUser,updateAt=now(),pvNum=:t.pvNum WHERE id=:t.id")
    void update(@SQLParam("t") ActionAdvertisement actionAdvertisement);
    
    @SQL("UPDATE ActionAdvertisement SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
    
    @SQL("UPDATE ActionAdvertisement SET releaseState=1 WHERE id=:1")
    void updateByReleaseStateIsPush(int id);
    
    @SQL("UPDATE ActionAdvertisement SET releaseState=0 WHERE id=:1")
    void updateByReleaseStateIsChannel(int id);
}